﻿//-----------------------------------------------------------------------
// <copyright file="GuildRankTest.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Common.Repository;
using GateShift.Common.Repository.Interfaces.DataInterfaces;
using GateShift.Services.GameData.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace GateShift.Testing.Services.GameData.Entities
{
    /// <summary>
    /// Summary description for GuildRankTest
    /// </summary>
    [TestClass]
    public class GuildRankTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region Name Validation

        [TestMethod]
        [ExpectedException(typeof(NullReferenceException))]
        public void Name_Null()
        {
            new GuildRank { Name = null };
        }

        [TestMethod]
        [ExpectedException(typeof(IndexOutOfRangeException))]
        public void Name_TooLong()
        {
            new GuildRank { Name = string.Empty.PadRight(21, 'A') };
        }

        [TestMethod]
        public void Name_Success()
        {
            IGuildRankData data = new GuildRank { Name = "TestName" };
            Assert.AreEqual("TestName", data.Name, "Mismatched Data");
        }

        [TestMethod]
        public void Name_Default()
        {
            IGuildRankData data = new GuildRank();
            Assert.AreEqual(null, data.Name, "Mismatched Data");
        }

        #endregion

        #region GuildID Reference

        [TestMethod]
        [ExpectedException(typeof(InvalidCastException))]
        public void GuildID_WrongIdentity()
        {
            new GuildRank { GuildID = new Identity(Guid.Empty) };
        }

        [TestMethod]
        public void GuildID_Success()
        {
            IGuildRankData data = new GuildRank { GuildID = new Identity((long)123) };
            Assert.AreEqual(123, (long)data.GuildID.Value, "Mismatched Data");
        }

        [TestMethod]
        public void GuildID_Default()
        {
            IGuildRankData data = new GuildRank();
            Assert.AreEqual(null, data.GuildID, "Mismatched Data");
        }

        #endregion
    }
}